package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.annotation.AddAnnotation;
import com.sky.annotation.UpdateAnnotation;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.pojo.Dish;
import com.sky.pojo.Setmeal;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Set;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    Page<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);

    @Insert("insert into setmeal values (null,#{categoryId},#{name}, #{price}, #{status},#{description},#{image},#{createTime}, #{updateTime}, #{createUser}, #{updateUser}, #{makeTime})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    @AddAnnotation
    int add(Setmeal setmeal);

    SetmealVO findById(Long id);
    @Update("update setmeal set name = #{name}, category_id = #{categoryId}, price = #{price}, image = #{image}, description = #{description}, status = #{status}, update_time = #{updateTime}, update_user = #{updateUser}, make_time = #{makeTime} where id = #{id}")
    @UpdateAnnotation
    int update(Setmeal setmeal);

    @Update("update setmeal set status = #{status} where id = #{id}")
    int startOrStop(Integer status, Long id);

    int deleteByIds(List<Long> ids);
}
